function debounce(fn: () => void, wait: number) {
    let timer: ReturnType<typeof setTimeout> | null = null
    return function(this: any, ...args: []) {
        if(timer) clearTimeout(timer)
        timer = setTimeout(() => {
            fn.apply(this, args)
        }, wait)
    }
}

function listener() {
    console.log('监听事件发生')
}

let scroll = debounce(listener, 500)



let n = 1
let ot = setInterval(() => {
    n++
    if(n >= 10) clearInterval(ot)
    if(n < 10) {
        scroll()
    } 
}, 60)

export {}